<extend name="Index:info"/>

<block name="body">

<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="" enctype="multipart/form-data">
      <div class="form-group">
        <div class="label">
          <label>文件名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="{$file.name}" name="name" data-validate="required:请输入标题" disabled />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>分类：</label>
        </div>
        <div class="field">
          <select name="file_category_id" class="input w50">
            <option value="0">请选择分类</option>

            <volist name="category" id="val">

                  <if condition="$val['id'] eq $file['file_category_id']">
                    <option value="{$val.id}" selected>{$val.category_name}</option>
                    <else/>
                    <option value="{$val.id}">{$val.category_name}</option>
                  </if>

            </volist>

          </select>
          <div class="tips"></div>
        </div>
      </div>

        <!--<div class="form-group">
          <div class="label">
            <label>分类标题：</label>
          </div>
          <div class="field">
            <select name="category_id" class="input w50">
              <option value="">请选择分类</option>
              <option value="">产品分类</option>
              <option value="">产品分类</option>
              <option value="">产品分类</option>
              <option value="">产品分类</option>
            </select>
            <div class="tips"></div>
          </div>
        </div>-->
       <!-- <div class="form-group">
          <div class="label">
            <label>其他属性：</label>
          </div>
          <div class="field" style="padding-top:8px;"> 
            首页 <input id="ishome"  type="checkbox" />
            推荐 <input id="isvouch"  type="checkbox" />
            置顶 <input id="istop"  type="checkbox" /> 
         
          </div>
        </div>-->

      <!--<div class="form-group">
        <div class="label">
          <label>描述：</label>
        </div>
        <div class="field">
          <textarea class="input" name="note" style=" height:90px;"></textarea>
          <div class="tips"></div>
        </div>
      </div>-->
      <div class="form-group">
        <div class="label">
          <label>内容：</label>
        </div>
        <div class="field">
          <textarea name="content"  id="ueditor">{$file.content}</textarea>
          <div class="tips"></div>
        </div>
      </div>
     
      <div class="clear"></div>

      <div class="form-group">
        <div class="label">
          <label>状态：</label>
        </div>
        <div class="field">
          <select name="auditor" class="input w50">
            <option value="0" >未通过</option>
            <if condition="$file['auditor'] eq 1">
              <option value="1" selected>通过</option>
              <else/>
              <option value="1">通过</option>
            </if>


          </select>
          <div class="tips">是否通过审核</div>
        </div>
      </div>

    <!--  <div class="form-group">
        <div class="label">
          <label>标签：</label>
        </div>
        <div class="field">

  <ul class="tag" style="background: #fff">
    <volist name="file.tag" id="val">
        <li><input name="tag[]" value="{$val.tag_name}"><span class="big">&times;</span></li>
    </volist>
    <li><input name="tag[]" value="添加标签" type="button"></li>
  </ul>


          <div class="tips">标签最多五个</div>
        </div>
      </div>-->
     <!-- <div class="form-group">
        <div class="label">
          <label>关键字：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="keywords" value=""/>
        </div>
      </div>-->
      <!--<div class="form-group">
        <div class="label">
          <label>排序：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="sort" value=""  data-validate="number:排序必须为数字" />
          <div class="tips"></div>
        </div>
      </div>-->
      <div class="form-group form-img">
        <div class="label">
          <label>图片：</label>
        </div>
        <div class="field">
          <div>
          <img src="__PUBLIC__/{$file.file_img_url}" height="110">
          </div>

           <input type="button" class="button bg-blue margin-left" id="btn_img" value="+ 浏览上传"  style="float:left;margin-top: 10px">
           <input type="file" class="button bg-blue margin-left" id="image"  style="display: none" name="file_img_url" accept="image/jpg,image/jpeg,image/png,image/gif">
           <div class="tipss"></div>

        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <input type="hidden" value="{$file.file_id}" name="code">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
  <script src="__PUBLIC__/home/js/ueditor/ueditor.config.js"></script>
  <script src="__PUBLIC__/home/js/ueditor/ueditor.all.js"></script>
<script>

    var editor = new UE.ui.Editor({ initialFrameWidth: $('.field').width()/2, initialFrameHeight:300});
    editor.render('ueditor');

    $('#btn_img').click(function () {

        $('#image').click();


    });

    $('#image').change(function () {

        var file = this.files[0];



        var reader = new FileReader();

        reader.readAsDataURL(file);
        reader.onload = function(e) {
            $("img").attr("src", this.result);

    }

    });


    $('.tag').on('click','.big',function () {
        $(this).parent().remove();
    });

    $(':button[name^=tag]').click(function () {

        var lenght =$('.tag li').length;

        if(lenght>5){
            alert('标签达到上限');
            return;
        }

        var html ='<li><input name="tag[]"><span class="big">&times;</span></li>';
       $(this).parent().before(html);
    });
</script>


</block>